You want to buy a $44.95 sweater, but might not have enough money.
PRINT "How much money do you have" INPUT CASH ' IF CASH >= 44.95 THEN PRINT "Buy the Sweater" ' true branch END IF ' PRINT "done" END
You (hopefully) picked a relational expression that was TRUE when the user COULD pay for the sweater.
Here is what happens for one run of the program:
How much money do you have ? 78.23 Buy the Sweater done
The true branch was executed because the relational expression was true. Here is another run of the program:
How much money do you have ? 14.96 done
The true branch is skipped because the
relational expression was FALSE.
Relational expressions always give TRUE or FALSE.
Use the correct relational symbol
(=
, >
, <
, and others)
to ask a question that will be TRUE when you
want the true branch to be executed.
Would the relational symbol <
have worked in
the above program?